<?php
	session_start();
	$shopInfo = array();
	if ($_SESSION['shopid'] != 0) {
		$shopid = $_SESSION['shopid'];
		require_once(Models_DIR.'page_model.php');
		$page_model = new Page_Model();
		$shopInfo = $page_model->showModInfo($shopid);

		if ($_SESSION[shopid] == 0) {
			$action = "addShopInfo";
		}else {
			$action = "modShopInfo";
		}

		$html = <<<code
			<form method="post" action="user" name="myForm" enctype="multipart/form-data">
				<input type="hidden" name="action" value="$action">
				<div class="dataform clearfix">
					<fieldset>
						<legend>餐廳基本資料</legend>
						<label for="restName">
							<span>餐廳名稱</span>
		        			<input type="text" name="restName" id="restName" placeholder="餐廳名稱" value="$shopInfo[0]">
						</label>	
						<label for="restSecName">
							<span>分店名稱(如果無分店寫"無")</span>
		          			<input type="text" name="restSecName" id="restSecName" placeholder="分店名稱(如果無分店寫"無")" value="無">
						</label>
						<label for="address">
							<span>店家地址</span>
		          			<input type="text" name="address" id="address" placeholder="店家地址" value="$shopInfo[1]">
						</label>
						<label for="phone">
							<span>店家電話EX:02-1234-1234</span>
		          			<input type="text" name="phone" id="phone" placeholder="店家電話" value="$shopInfo[2]">
						</label>
					</fieldset>
					<fieldset>
						<legend>餐廳資料</legend>	
						<label for="content">
							<span>餐廳介紹</span>
		          			<textarea name="content" id="content" placeholder="餐廳介紹">$shopInfo[3]</textarea>
						</label>
						<label>
							<span style="float:none;">推薦菜單(檔名使用英文)</span>
								<input type="text" name="food1_txt" id="ttexc" value="$shopInfo[4]">
			            		<input type="file" name="file0" id="ttexc">
								<input type="text" name="food2_txt" id="ttexc" value="$shopInfo[5]">
								<input type="file" name="file1" id="ttexc">
								<input type="text" name="food3_txt" id="ttexc" value="$shopInfo[6]">
								<input type="file" name="file2" id="ttexc">
								<input type="text" name="food4_txt" id="ttexc" value="$shopInfo[7]">
								<input type="file" name="file3" id="ttexc">	
		              	</label>	
						<label for="shopPhoto">
							<span>店面照片</span>
							<input type="file" name="shopPhoto" id="shopPhoto">
						</label>
					
					<label for="table">
						<span></span>

					</label>
					<label for="maxNumber">
						<span>最大可供訂位數量(請填數字)</span>
						<input type="text" name="maxNumber" id="maxNumber" class="input_text" value="$shopInfo[8]">
					</label>
					<label for="singleNumber">
						<span>單筆訂位數量(請填數字)</span>
						<input type="text" name="singleNumber" id="singleNumber" class="input_text" value="$shopInfo[9]">
					</label>
				<fieldset>

					<input type="reset" value="重置" class="button">	
					<input id="go" name="go" type="submit" value="下一頁" class="button">
				</div>
			</form>

		<!-- JS -->
code;
		$html .= '<script src="'. LIB_DIR .'jquery.validate.js'. '"></script>';
		$html .=<<< code
		<script type="text/javascript">
			
				$('#dataForm').validate({
					debug: true,
					rules: {
						restName: "required",
						restSecName: "required",
						address: "required",
						phone: "required",
						maxNumber: {
							required: true,
							digits: true
						},
						singleNumber: {
							required: true,
							digits: true
						}
					}
				});
			
		</script>
code;
	echo $html;
	}
?>


